import { initGlobalState } from "qiankun";
import globalState from "./globalState";

export default () => {
  if (!window.$microAppStateActions) {
    // // 全局状态机
    const actions = initGlobalState(globalState);

    // 将action对象绑定到全局
    window.$microAppStateActions = actions;
  }

  // // 在项目中任何需要监听的地方进行监听，在这里监听是为了方便
  window.$microAppStateActions.onGlobalStateChange((state, prev) => {
    // eslint-disable-line no-unused-vars

    console.log("主应用监听全局状态机", state);
  });
};
